<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('导入表结构')" />
</head>
<body class="gray-bg">
     <div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="md-table-form">
					<div class="select-list">
						<input id="tableId" name="tableId"  type="hidden"/>
					</div>
				</form>
			</div> 
	</div>
    <div class="container-div">
		<div class="row">
		    <div class="col-sm-12 select-table table-striped">
			    <table id="mdFieldDialogTable"></table>
			</div>
		</div>
	</div>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
        var prefix = ctx + "verify/rule";
		$(function() {
			 var sysId = window.parent.document.getElementById("tableId").value;
	         $("#tableId").val(sysId);
		    var options = {
		    	url: prefix + "/showMdFieldList",
		        sortName: "createTime",
		        sortOrder: "desc",
		        showSearch: false,
		        showRefresh: false,
		        showToggle: false,
		        showColumns: false,
		        clickToSelect: true,
		        rememberSelected: true,
		        uniqueId: "md_field",
		        modalName: "字段MD定义",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'fieldId',
                    title: '字段信息Id',
                    visible: false
                },
                {
                    field: 'fieldCode',
                    title: '字段代码'
                },
                {
                    field: 'fieldName',
                    title: '字段名称'
                },
                {
                    field: 'fieldContent',
                    title: '字段说明'
                },
                {
                    field: 'fieldType',
                    title: '字段类型'
                },
                {
                    field: 'fieldLength',
                    title: '字段长度'
                },
                {
                    field: 'fieldPrecision',
                    title: '字段精度'
                },
                {
                    field: 'fieldCanNull',
                    title: '是否可空'
                },
                {
                    field: 'fieldDefault',
                    title: '字段默认值'
                },
                {
                    field: 'fieldCanNegative',
                    title: '是否可为负数'
                },
                {
                    field: 'fieldEnumRange',
                    title: '枚举值域'
                },
                {
                    field: 'tableId',
                    title: '表id'
                }]
		    };
		    $.table.init2(options,"mdFieldDialogTable");
		});
		
		/* 导入表结构-选择表结构-提交 */
		function submitHandler() {
			var rows = $.table.selectColumns("tableName");
			if (rows.length == 0) {
       			$.modal.alertWarning("请至少选择一条记录");
       			return;
       		}
			var data = {"tables": rows.join()};
			$.operate.save(prefix + "/importTable", data);
		}
	</script>
</body>
</html>